package com.example.library_common.album.media_reader;

import androidx.annotation.WorkerThread;

import com.example.library_common.R;
import com.example.library_common.album.bean.AlbumFolder;
import com.example.library_common.global.AppGlobals;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AllMediaReader implements AlbumMediaReader {

    @Override
    @WorkerThread
    public void scanMediaFile(Map<String, AlbumFolder> albumFolderMap, AlbumFolder allFileFolder) {

    }

    @Override
    @WorkerThread
    public List<AlbumFolder> getAllMediaFile() {
        Map<String, AlbumFolder> albumFolderMap = new HashMap<>();
        AlbumFolder allFileFolder = new AlbumFolder();
        allFileFolder.setChecked(true);
        allFileFolder.setName(AppGlobals.getApplication().getString(R.string.album_all_images_videos));

        ImageMediaReader imageReader=new ImageMediaReader();
        imageReader.scanMediaFile(albumFolderMap, allFileFolder);

        VideoMediaReader videoReader=new VideoMediaReader();
        videoReader.scanMediaFile(albumFolderMap, allFileFolder);
//        scanImageFile(albumFolderMap, allFileFolder);
//        scanVideoFile(albumFolderMap, allFileFolder);

        ArrayList<AlbumFolder> albumFolders = new ArrayList<>();
        Collections.sort(allFileFolder.getAlbumFiles());
        albumFolders.add(allFileFolder);

        for (Map.Entry<String, AlbumFolder> folderEntry : albumFolderMap.entrySet()) {
            AlbumFolder albumFolder = folderEntry.getValue();
            Collections.sort(albumFolder.getAlbumFiles());
            albumFolders.add(albumFolder);
        }
        return albumFolders;
    }
}
